﻿@model IEnumerable<DistributeTransaction.Models.WatchList>
@{
    ViewBag.Title = "Watch List";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var grid = new WebGrid(source: Model);
}
<h2>
    Watch List</h2>
@using (Html.BeginForm())
{
    <fieldset>
        <legend></legend>
        @grid.GetHtmlWithSelectAllCheckBox(
                tableStyle: "grid",
                checkBoxValue: "ProductID",
                columns: grid.Columns(
                       grid.Column(columnName: "ProductName", header: "Product Name", style: "text-align-center"),
                       grid.Column(columnName: "UnitPrice", header: "Price", style: "text-align-right"),
                       grid.Column(columnName: "QuantityPerUnit", header: "Decription", style: "text-align-center"),
                       grid.Column(columnName: "CompanyName", header: "Manufacturer", style: "text-align-center")
            ))
        <p></p> 
        <div>
            <input type="submit" name="command" id="Delete" value="Delete" disabled="disabled" />
            <input type="submit" name="command" id="Add"  value="Add To ShoppingCart" disabled="disabled" />
        </div>
    </fieldset>
    <script type="text/javascript" language="javascript">
        $("#allCheckBox").live('change', function () {
            if ($(this).attr("checked") || $(this).attr("indeterminate")) {
                $("#Delete").removeAttr("disabled");
                $("#Add").removeAttr("disabled");
            } else {
                $("#Delete").attr("disabled", "disabled");
                $("#Add").attr("disabled", "disabled");
            }
        });
        $('.singleCheckBox').live('change', function () {
            if ($("#allCheckBox").attr("checked") || $(this).attr("checked") ) {
                $("#Delete").removeAttr("disabled");
                $("#Add").removeAttr("disabled");
            } else {
                $("#Delete").attr("disabled", "disabled");
                $("#Add").attr("disabled", "disabled");
            }
        });
        $(function () {
            $('#Delete').click(function () {
                var ret = confirm('Are you sure you wish to delete these item(s)?');
                if (ret) {
                    $('form').submit();
                }
                return ret;
            });
        });
    </script>
}
